package controllers

import "hw_admin/models"

//用户管理controller
type UserController struct {
	BaseController
}

//用户列表
func (this *UserController) List() {

	var adminUser models.AdminUser
	//获取前端传入的数据
	pageNo,_  := this.GetInt("pageNo",1)
	pageSize,_  := this.GetInt("pageSize",10)
	beginTime := this.GetString("beginTime","")
	endTime := this.GetString("endTime","")
	userName := this.GetString("userName","")

	users,count,err := adminUser.GetList(pageNo,pageSize,beginTime,endTime,userName)
	if err == nil {
		page := this.GetPage(count,pageNo,pageSize)
		this.Data["page"] = page
		this.Data["count"] = count
		this.Data["users"] = users
	}
	//跳转的页面
	this.TplName = "admin-list.html"

}

//修改页面
func (this *UserController) UpdateView()  {
	var user models.AdminUser
	id,_ := this.GetInt64("id",0)
	if id != 0 {
		//获取用户信息
		user.GetById(id)
		roles,_ := models.AdminRole{}.GetRole()
		this.Data["user"] = user
		this.Data["roles"] = roles
	}
	this.TplName = "admin-edit.html"
}

//用户添加页面
func (this *UserController) InsertView(){
	roles,err := models.AdminRole{}.GetRole()
	if err == nil {
		this.Data["roles"] = roles
	}
	this.TplName = "admin-add.html"
}

//保存
func (this *UserController) Insert()  {

}

